/** 
* Descripttion:  Copyright (c) 2020 Sprocomm. All rights reserved.
* version:  V1.0 
* Author:  Sprocomm
* Date: 2020-10-22 08:59:11
* LastEditors:  Sprocomm
* LastEditTime: 2020-10-22 11:08:48
**/

#include <iostream>
#include <algorithm>
#include <numeric>

#include <gtest/gtest.h>

using namespace std;

class BaseBarcode{
public:
    BaseBarcode(){std::cout << "BaseBarcode" << std::endl;}
    
    ~BaseBarcode(){}

    virtual void get_color(){
        std::cout << "Base color" << std::endl;
    }
};

class Code128 : public BaseBarcode
{
private:
    /* data */
public:
    Code128(int a){
        std::cout << "Code128" << std::endl;
    }
    ~Code128(){}

    void get_dim(){
        std::cout << "get_dim" << std::endl;
    }
};

/** 
* description: dynamic_cast<pointer>(e)主要是把父类转换为子类，并且
* 能够调用子类中的函数，这个函数父类中没有。
* param {*}
* return {*}
**/
TEST(test_code128, get_dim){
    BaseBarcode* bar = new Code128(0);
    Code128* code = dynamic_cast<Code128*>(bar);
    code->get_dim();
}

TEST(test_code128s, get_dim){
    BaseBarcode* bar = new Code128(0);
    Code128* code = static_cast<Code128*>(bar);
    ASSERT_TRUE(code) << "转换失败";
    
    code->get_dim();
}

TEST(test_accu, std){
    char counters[10];
    for(int i=0; i<10; i++){
        counters[i] = i;
    }
    int sum = std::accumulate(counters, counters+10, 0);
    std::cout << "sum = " << sum << std::endl;

    std::cout << "std::numeric_limits<float>::max():" << std::numeric_limits<float>::max() << std::endl;
}